#include "HtBaseSubject.h"


CHtBaseSubject::CHtBaseSubject()
{
}


CHtBaseSubject::~CHtBaseSubject()
{
}

void CHtBaseSubject::AddObserver(CHtObserver *observer)
{
	for (auto _obs : m_observerlist)
	{
		if (_obs == observer)
			return;
	}
	m_observerlist.push_back(observer);
}

void CHtBaseSubject::delObserver(CHtObserver *observer)
{
	auto _obs = m_observerlist.begin();
	while (_obs != m_observerlist.end())
	{
		if (*_obs == observer)
		{
			m_observerlist.erase(_obs);
			return;
		}
		_obs++;
	}
}

void CHtBaseSubject::Update(unsigned int nMSG, UINT_PTR wparam, LONG_PTR lparam)
{
	for (auto _obs : m_observerlist)
	{
		if (_obs)
			_obs->Update(nMSG, wparam, lparam);
	}
}

void CHtBaseSubject::RemoveAll()
{
	if (m_observerlist.size()>0)
		m_observerlist.clear();
}
